#include <bits/stdc++.h>
// 2025/01/31
// tag:
// Author: Zhang Muen
using namespace std;

int enter[501], out[501], n, m, vis[501];
multiset<int> graph[501];
stack<int> ans;

void dfs(int x)
{
    for (auto it = graph[x].begin(); it != graph[x].end();) {
        int y = *it;
        graph[x].erase(it);
        graph[y].erase(graph[y].find(x));
        dfs(y);
        it = graph[x].begin();
    }
    ans.push(x);
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        graph[u].insert(v);
        graph[v].insert(u);
        enter[v]++, enter[u]++;
        out[u]++, out[v]++;
    }
    int s = 0, s1 = 0;
    for (int i = 1; i <= 500; i++){
        if (out[i] ^ 1 && out[i] != 0 && !s1)
            s1 = i;
        if (out[i] & 1 && !s)
            s = i;
    }
    if (!s)
        s = s1;
    dfs(s);
    for (int j = 0; j <= m; j++) {
        cout << ans.top() << endl;
        ans.pop();
    }
    return 0;
}